@extends('wx.layout.default')

@section('wx.pheader')
  @include('wx.layout.swiper')
@stop

@section('wx.pbody')
  {{ csrf_field() }}
  <input type="hidden" name="detail_id" value="{{$detail->id}}" />
  <input type="hidden" name="uid" value="{{$user->id}}" />
  <div class="weui-panel">
    <div class="weui-panel__hd">学生信息</div>
    <div class="weui-panel__bd">
      <div class="weui-media-box weui-media-box_small-appmsg">
        <div class="weui-cells">
          <div class="weui-cell">
            <div class="weui-cell__bd">姓名</div>
            <span class="weui-cell__ft">{{$user->name}}</span>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__bd">手机号码</div>
            <span class="weui-cell__ft">{{$user->mobile}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="weui-panel">
    <div class="weui-panel__hd">班级信息</div>
    <div class="weui-panel__bd">
      <div class="weui-media-box weui-media-box_small-appmsg">
        <div class="weui-cells">
          <div class="weui-cell">
            <div class="weui-cell__bd">学期</div>
            <span class="weui-cell__ft">{{$detail->publish->term->name}}</span>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__bd">门类</div>
            <span class="weui-cell__ft">{{$detail->category->name}}</span>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__bd">班级</div>
            <span class="weui-cell__ft">{{$detail->clase->name}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>


  <div class="weui-btn-area" style="margin-bottom: 0;">
    <button class="submit weui-btn weui-btn_primary">加入班级花名册</button>
  </div>

@stop

@section('javascript')
  <script src="//cdn.bootcss.com/jquery-weui/1.2.1/js/swiper.min.js"></script>
  <script src="//cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
  <script type="text/javascript">
    $(function() {

      $('.submit').on('click', function () {
          var uri = '{{route('wx.settle.student')}}';

          $.post(uri, {
              '_token': $("input[name='_token']").attr('value'),
              'did': $("input[name='detail_id']").val(),
              'uid': $("input[name='uid']").val(),
              'is_submit': true
          }, function (data) {
            layer.msg(data.message, {time: 1000, shift: -1}, function () {
              if (data.status === true && data.url != null) {
                $(window).attr('location', data.url);
              }
            });
          }, 'json').error(function (data) {
              layer.msg(data.responseJSON.message);
          });
      });

      $('.swiper-container').swiper({
        loop: true,
        autoplay: 5000,
        pagination: '.swiper-pagination',
        paginationClickable: true
      });

    });
  </script>
@stop